package com.vincent.program;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Hotel {
	public static final PriceType REGULAR_WEEKDAY = new PriceType(
			PriceType.REGULAR, PriceType.WEEKDAY);
	public static final PriceType REGULAR_WEEKEND = new PriceType(
			PriceType.REGULAR, PriceType.WEEKEND);
	public static final PriceType REWARDS_WEEKDAY = new PriceType(
			PriceType.REWARDS, PriceType.WEEKDAY);
	public static final PriceType REWARDS_WEEKEND = new PriceType(
			PriceType.REWARDS, PriceType.WEEKEND);

	private int rate;
	private String name;
	private Map<PriceType, Double> priceStrategy = new HashMap<PriceType, Double>();

	public Hotel(String name, int rate, double regularWeekdayPrice,
			double regularWeekendPrice, double rewardsWeekdayPrice,
			double rewardsWeekendPrice) {
		super();
		this.rate = rate;
		this.name = name;

		this.priceStrategy.put(this.REGULAR_WEEKDAY, regularWeekdayPrice);
		this.priceStrategy.put(this.REGULAR_WEEKEND, regularWeekendPrice);
		this.priceStrategy.put(this.REWARDS_WEEKDAY, rewardsWeekdayPrice);
		this.priceStrategy.put(this.REWARDS_WEEKEND, rewardsWeekendPrice);
	}

	public static Hotel lakewood() {
		return new Hotel("Lakewood", 3, 110, 90, 80, 80);
	}

	public static Hotel bridgewood() {
		return new Hotel("Bridgewood", 4, 160, 60, 110, 50);
	}

	public static Hotel ridgewood() {
		return new Hotel("Ridgewood", 5, 220, 150, 100, 40);
	}

	private double findPriceByType(PriceType type) {
		return this.priceStrategy.get(type);
	}

	public int getRate() {
		return rate;
	}

	public void setRate(int rate) {
		this.rate = rate;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Map<PriceType, Double> getPriceStrategy() {
		return priceStrategy;
	}

	public void setPriceStrategy(Map<PriceType, Double> priceStrategy) {
		this.priceStrategy = priceStrategy;
	}

	public double calculateFee(List<PriceType> types) {
		double sum = 0d;
		for (PriceType type : types) {
			sum += this.findPriceByType(type);
		}
		return sum;
	}

}
